<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>修改密码</title>
  <link rel="stylesheet" href="${ctx}/static/admin/layui/css/layui.css">
  </head>
    <body>
    <div class="layui-card-body">
  	<form class="layui-form layui-form-pane">
	  <div class="layui-form-item">
	    <label class="layui-form-label">原密码</label>
	    <div class="layui-input-block">
	      <input type="password" name="oldPwd" lay-verify="required" placeholder="请输入原密码" autocomplete="off" class="layui-input">
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label">新密码</label>
	    <div class="layui-input-block">
	      <input type="password" name="newPwd" lay-verify="required|pass" placeholder="请输入新密码" autocomplete="off" class="layui-input">
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label">重复新密码</label>
	    <div class="layui-input-block">
	      <input type="password" name="pwdRepeat" lay-verify="required" placeholder="请重复输入新密码" autocomplete="off" class="layui-input">
	    </div>
	  </div>
	  <div class="layui-form-item" style="display: none">
	    <div class="layui-input-block">
	      <button class="layui-btn" id="submit-btn" lay-submit>立即提交</button>
	      <button type="reset" id="reset-btn" class="layui-btn">重置</button>
	    </div>
	  </div>
	</form>
	</div>
  </body>
</html>
<script src="${ctx}/static/admin/layui/layui.js"></script>
<script>
layui.use(['jquery','form'], function(){
  var $ = jQuery = layui.$;
  var form = layui.form;
  
  form.verify({
      pass: function (value) {
          if (value.length < 8) {
        	  return '密码最低8位！';
          }
          if (!(/(?!^(\d+|[a-zA-Z]+|[~!@#$%^&*?]+)$)^[\w~!@#$%^&*?]{8,20}$/.test(value))) {
        	  return '密码必须包括字母、数字、特殊字符中的任意2种！';
          }
          /*if (!(/^.*(?=.*\d)(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&*?\(\)]).*$/.test(value))) {
        	  return '密码必须包含大小写字母+数字+特殊字符！';
          }*/
      }
  });
  
  //监听提交
  form.on('submit', function(data){
	  $.post('${ctx}/sys_admin/main/updPwd', data.field, function(result) {
			if (result.success) {
				var index = parent.layer.getFrameIndex(window.name);
				parent.layer.close(index); //再执行关闭   
				parent.layer.msg("修改密码成功！");
			} else {
				layer.msg(result.msg);
			}
		}, 'json');
	  return false;
  });
});
</script>